package com.home.System;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

import com.home.Entity.Ban;
import com.home.Entity.CTHoaDon;
import com.home.Entity.CTQuyenSuDung;
import com.home.Entity.CaLamViec;
import com.home.Entity.ChamCong;
import com.home.Entity.DKCaLamViec;
import com.home.Entity.DVT;
import com.home.Entity.HoaDon;
import com.home.Entity.KhuVucBan;
import com.home.Entity.KhuyenMai;
import com.home.Entity.Mon;
import com.home.Entity.MuaThietBi;
import com.home.Entity.NguyenLieu;
import com.home.Entity.NhanVien;
import com.home.Entity.NhapXuatNL;
import com.home.Entity.NhomMon;
import com.home.Entity.QuanCoffee;
import com.home.Entity.QuyenSuDung;
import com.home.Entity.TTGoiMon;
import com.home.Entity.TTPhaChe;
import com.home.Entity.TaiKhoan;
import com.home.Entity.ThietBi;
import com.home.Entity.ThuongPhat;
public class HibernateUtil {
	private static final SessionFactory sessionFactory;
	 
	 static {
	        try {
	           sessionFactory = new AnnotationConfiguration()
	                              .configure()
	                              .addAnnotatedClass(Ban.class)
	                              .addAnnotatedClass(CaLamViec.class)
	                              .addAnnotatedClass(ChamCong.class)
	                              .addAnnotatedClass(CTHoaDon.class)
	                              .addAnnotatedClass(CTQuyenSuDung.class)
	                              .addAnnotatedClass(DKCaLamViec.class)
	                              .addAnnotatedClass(DVT.class)
	                              .addAnnotatedClass(HoaDon.class)
	                              .addAnnotatedClass(KhuVucBan.class)
	                              .addAnnotatedClass(KhuyenMai.class)
	                              .addAnnotatedClass(Mon.class)
	                              .addAnnotatedClass(MuaThietBi.class)
	                              .addAnnotatedClass(NguyenLieu.class)
	                              .addAnnotatedClass(NhanVien.class)
	                              .addAnnotatedClass(NhapXuatNL.class)
	                              .addAnnotatedClass(NhomMon.class)
	                              .addAnnotatedClass(QuanCoffee.class)
	                              .addAnnotatedClass(QuyenSuDung.class)
	                              .addAnnotatedClass(TaiKhoan.class)
	                              .addAnnotatedClass(ThietBi.class)
	                              .addAnnotatedClass(ThuongPhat.class)
	                              .addAnnotatedClass(TTGoiMon.class)
	                              .addAnnotatedClass(TTPhaChe.class)
	                              .buildSessionFactory();
	           
	
	     } catch (Throwable ex) {
	            System.err.println("Initial SessionFactory creation failed." + ex);
	         throw new ExceptionInInitializerError(ex);
	      }
	   }
	 
	   public static SessionFactory getSessionFactory() {
	     return sessionFactory;
	  }
}
